/* SquareOnBoard.java
 * Auti i method parousiazi ena Square pano sto Chess Board.
 * Boris na kani add kai remove ena piece( pou ine Jlable / Component).
 */

package GUI;

import java.awt.*;
import javax.swing.*;
 
public class SquareOnBoard extends JPanel{
    
    /**
     * Kali ton Constractor super();
     */
    public SquareOnBoard(){ super(); }
    
    /**
     * 
     * @param name To onoma tou Piece pou tha perilamvani tis parametrous xy, 01 => x=0, y=1.
     */
    public SquareOnBoard(String name){
        this();
        setName(name);
    }
    
    /**
     * 
     * @param name Theti to onoma tou piece pou apotelite apo tis sindetagmenes tou
     */
    public void setSquareName(String name){ setName(name); }
    
    /**
     * 
     * @param p Ena andikimeno tipou Piece pou prosthetete sto panel.
     */
    public void addPiece(sqrGUI p){
        add(p);
        paintAll(getGraphics());
    }
    
    /**
     * An iparhoun Pieces ta aferi apo to Board.
     */
    public void removePiece(){
        if(getComponentCount() > 0){
            remove(0);
            paintAll(getGraphics());
        }
    }
    
    /**
     * Accessor.
     * Theti to Hroma tou Square kai to kani paint sto Chess Board.
     * @param c To hroma tou Square.
     */
    public void setSquareColor(Color c){
        setBackground(c);
        paintAll(getGraphics());
    }
    
//    /**
//     * 
//     * @return Epistrefi mia boolean me true/false analoga me to an to Chess Board ine Empty ( getComponentCount()=0 ) i ohi.
//     */
//    public boolean isEmpty(){
//        if(getComponentCount() == 0)
//            return true;
//        else
//            return false;
//    }
//    
//    /**
//     *
//     * @return Ton arithmos ton Piece pou vriskonde sto Chess Board.
//     */
//    public int getNumOfComponents(){ return getComponentCount(); }
//    
//    /**
//     * @return To Piece sto sigekrimeno Square.
//     */
//    public sqrGUI getPieceOnSquare(){
//        if(getComponentCount() > 0)
//            return (sqrGUI)getComponent(0);
//        else 
//            return null;
//    }
}